import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        theme: ThemeData(
          useMaterial3: false,
          primarySwatch: Colors.blue,
        ),
        home: const MyHome()
    );
  }
}

class MyHome extends StatefulWidget {
  const MyHome({super.key});

  @override
  State<MyHome> createState() => _MyHomeState();
}

class _MyHomeState extends State<MyHome> {

  bool flag = true;

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("Flutter App"),
      ),
      body: Center(
        //带动画效果的container
        child: AnimatedContainer(
          width: flag ? 200 : 300,
          height: flag ? 200 : 300,
          color: flag ? Colors.yellow : Colors.blue,
          duration: const Duration(seconds: 1),   //设置动画时长
          //设置移动效果,可以在xyz轴上进行移动
          transform: flag ? Matrix4.translationValues(0, 0, 0) : Matrix4.translationValues(-50, 0, 0),
        ),
      ) ,
      floatingActionButton: FloatingActionButton(
        onPressed: () {
            setState(() {
              flag = !flag;
            });
        },
        child: const Icon(Icons.refresh),
      ),
    );
  }
}

